import request from '@/axios'
import type { CurdData } from '../types'

//商品报价列表
export const getListApi = (params: any) => {
  return request.get({ url: '/admin/product_price', params })
}

//商品报价-编辑 查询商品报价详情
export const getEditInfoApi = (id: string, params: any): any => {
  return request.get({ url: `/admin/product_price/${id}`, params })
}

//商品报价-编辑 保存 （页面保存）
export const saveEditApi = (data: any): any => {
  return request.put({ url: '/admin/product_price', data })
}

//商品报价-编辑 保存 （后台保存）
export const updatePriceApi = (data: any): any => {
  return request.put({ url: '/admin/product_price/update_price', data })
}

//商品报价-更新可售状态
export const setSaleStatusApi = (data): Promise<IResponse> => {
  return request.post({ url: 'admin/inventory/sale', data })
}
//商品报价-编辑 获取静态表单回显
export const getInfoApi = (id: string): Promise<IResponse<CurdData>> => {
  return request.get({ url: '/admin/warehouse/' + id })
}
//商品报价列表-获取枚举
export const getEnumApi = (params: any) => {
  return request.get({ url: '/admin/inventory/resource', params })
}
//商品报价-获取导入模版
export const getImportTemplateApi = (params = {}, filename: string): any => {
  return request.exportFile({ method: 'post', url: `/admin/template`, params, filename })
}
// //商品报价-编辑 保存
// export const saveEditApi = (data: any): any => {
//   return request.post({ url: '/admin/inventory/fixSavePrice', data })
// }

//商品报价-编辑 获取币种下拉框数据
export const getCurrencyApi = (id: string): any => {
  return request.get({ url: `/admin/warehouse/getCurrencySelect?wid=${id}` })
}
//商品报价-编辑 获取动态表单回显
export const getEditBackShowApi = (id: string): any => {
  return request.get({ url: `/admin/inventory/${id}` })
}
//商品报价-编辑 获取是否可售枚举
export const getSalesEnumListApi = (params: any) => {
  return request.get({ url: '/admin/inventory/fieldEnum', params })
}
//导出
export const exportFileApi = (params = {}, filename: string) => {
  return request.exportFile({
    method: 'post',
    url: '/admin/inventory/exportPrice',
    params,
    filename
  })
}

export const getProductListApi = (params: any) => {
  return request.get({ url: '/admin/product', params })
}
